package com.xinchengxd.email.receiver;

import com.xinchengxd.commons.entity.dto.MailDTO;
import com.xinchengxd.email.service.EmailService;
import com.xinchengxd.email.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author: 姚新成
 * @Date: 2021/11/19:8:25
 * @Description:
 */

@Slf4j
@Component
@RabbitListener(queues = {"yxc_mail_queue"})   //指定监听哪些队列
public class EmailReceiver {
    @Autowired
    private EmailService emailService;

    @RabbitHandler   //处理消息的方法
    public void receive(MailDTO email) {
        log.debug("接收的信息：{}", email);

        /*发送数据*/
        emailService.emailSend(email,1);
    }

    @RabbitHandler   //处理消息的方法
    public void receive(String sub) {
        log.debug("sub接收的信息：{}", sub);
//        mailService.sendMail(email);
    }
}
